package isv

import (
	"dhfshop/models/isv"
	"dhfshop/controllers/base"
	//"github.com/astaxie/beego"
)

//客户表 账目描述
type CustAccountController struct {
	base.BaseController
}

func (this *CustAccountController) List() {
	query,_,fields,order_by,offset,limit,err := this.GetQueryPara()
	if err != nil {
	   this.ServeError(err.Error())
	   return
	}
	var allowStoreId []int64
	if this.CurrentUser != nil {
	    allowStoreId = this.CurrentUser.AllowStoreId
	}
	//beego.Debug("allowStoreId:", allowStoreId)
	l, num, err := isv.GetAllCustAccounts(allowStoreId,query,fields,order_by,offset,limit)
	if err != nil {
	    this.ServeError(err.Error())
	    return
	   
	} 
	r := struct {
	       TotalCount  int64                  `json:"total_count"`
	       CustAccounts   []*isv.CustAccount  `json:"cust_account"`
	    }{TotalCount: num, CustAccounts: l}
	this.Data["json"] = r
	this.ServeJSON()
}
